<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
/******************************************************************
*Server    :  <xsl:value-of select="//Server"/>
*Database  :  <xsl:value-of select="//Database"/>  
*name  :  dbo.UP_<xsl:value-of select="//Meta/Name"/>_Insert
*function  :  
*author    :  <xsl:value-of select="//Author"/>
*CreateDate   :  <xsl:value-of select="//CreateDate"/>
*Description  :  
*Reference Version : V1.0
=====================================================================
*change history
----------------------------------------------------------
*V1.0
*Date  : <xsl:value-of select="//CreateDate"/>
*Modify by : <xsl:value-of select="//Author"/>
*Description  : 
********************************************************************/
CREATE PROCEDURE dbo.UP_<xsl:value-of select="//Meta/Name"/>_Insert
<xsl:for-each select="//Meta/Columns/Column[IsPrimaryKey!='true' and AutoIncrement!='true']">
      @<xsl:value-of select="Name"/>
				<xsl:text>&#9;</xsl:text>
				<xsl:value-of select="ColumnType"/><xsl:text>&#9;</xsl:text><xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>

AS

INSERT INTO <xsl:value-of select="//Meta/Name"/>(<xsl:for-each select="//Meta/Columns/Column">
			<xsl:if test="AutoIncrement!='true'">
				<xsl:text>&#9;</xsl:text><xsl:value-of select="Name"/>
				<xsl:if test="position()!=last()">,&#10;</xsl:if>
			</xsl:if>
		</xsl:for-each>)
VALUES(<xsl:for-each select="//Meta/Columns/Column">
			<xsl:if test="AutoIncrement!='true'">	@<xsl:value-of select="Name"/>
				<xsl:if test="position()!=last()">,&#10;</xsl:if>
			</xsl:if>
		</xsl:for-each>)
<xsl:for-each select="//Meta/Columns/Column[IsPrimaryKey='true' and AutoIncrement='true']">
    SELECT scope_identity()
</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
